home *** CD-ROM | disk | FTP | other *** search
Modula Implementation | 1997-04-23 | 1.4 KB | 66 lines | [TEXT/3PRM] |
- implementation module event;
-
- import StdInt, StdBool;
- import events, desk;
- import commonDef;
-
- :: *EVENTS :== Int;
-
- EventError :: String String -> .x;
- EventError f error = Error f "event" error;
-
- // Opening and closing event streams EVENTS from the World:
-
- OpenEvents :: !*World -> (!EVENTS, !*World);
- OpenEvents world
- | 0 == (2 bitand w) = OpenEvents2 (StoreWorld (w bitor 2) world);
- = EventError "OpenEvents:" "This world doesn't contain events";
- where {
- w = LoadWorld world;
- };
-
- OpenEvents2 :: !* World -> (!EVENTS, !* World);
- OpenEvents2 w = code {
- pushI 0
- };
-
- LoadWorld :: !World -> Int;
- LoadWorld w = code{
- pushI_a 0
- pop_a 1
- };
-
- StoreWorld :: !Int !World -> * World;
- StoreWorld i w = code {
- fillI_b 0 1
- pop_b 1
- pop_a 1
- };
-
- CloseEvents :: !EVENTS !*World -> *World;
- CloseEvents e world
- = CloseEvents2 e (StoreWorld (LoadWorld world bitand (-3)) world);
-
- CloseEvents2 :: !EVENTS !*World -> *World;
- CloseEvents2 e w = code {
- pop_b 1
- fill_a 0 1
- pop_a 1
- };
-
- EmptyEVENTS :: *EVENTS;
- EmptyEVENTS = -1;
-
- IsEmptyEVENTS :: EVENTS -> Bool;
- IsEmptyEVENTS -1 = True;
- IsEmptyEVENTS _ = False;
-
- GetEvent :: !Int !Toolbox -> (!Event,!Toolbox);
- GetEvent mask tb
- | interesting || what == NullEvent
- = ((interesting,what,message,i,h,v,modifiers), tb1);
- = GetEvent mask (SystemTask tb1);
- where {
- (interesting,what,message,i,h,v,modifiers,tb1) = GetNextEvent mask tb;
- };
-